package org.eclipse.football;

import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;


public class League {
	// Define private member variables
	private ArrayList<Team> teams = new ArrayList<Team>();

	// Define a constructor
	public League(){
		// Instantiate file object with input file name
		File in_file = new File("league.txt");
		
		// Check if in_file exists
		if(in_file.exists()){
			// If so try to instantiate a scanner
			Scanner scanner;
			try {
				scanner = new Scanner(new FileReader(in_file));
				
				
				// Read the number of teams from the first line of the file
				int num_teams = Integer.parseInt(scanner.nextLine().split("\n")[0]);
				
				// Iterate for each team
				for(int i = 0; i < num_teams; i++){
					// Read the team name for this team from the next line
					String team_name = scanner.nextLine().split("\n")[0];
					
					// Create a team with this name
					Team team = new Team(team_name);
					
					// Read the number of off_players on this team from the next line
					int num_players = Integer.parseInt(scanner.nextLine().split("\n")[0]);
					
					// Iterate for each off_player
					for(int j = 0; j < num_players; j++){
						// Read the name of this player from the next line
						String player_name = scanner.nextLine().split("\n")[0];
						
						// Create an off_player with this name
						OffPlayer player = new OffPlayer(player_name);
						
						// Get this players pass_yds and set that in player
						player.setPass_yds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
										
						// Get this players pass_tds and set that in player
						player.setPass_tds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players picks and set that in player
						player.setPicks(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players pass_2pt and set that in player
						player.setPass_2pt(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rush_yds and set that in player
						player.setRush_yds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rush_tds and set that in player
						player.setRush_tds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rush_2pt and set that in player
						player.setRush_2pt(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rec_yds and set that in player
						player.setRec_yds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rec_tds and set that in player
						player.setRec_tds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players rec_2pt and set that in player
						player.setRec_2pt(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players fumbles and set that in player
						player.setFumbles(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players ret_tds and set that in player
						player.setRet_tds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Add this off_player to team
						team.addOffPlayer(player);
					}
					
					// Get the number of defensive players from the next line
					num_players = Integer.parseInt(scanner.nextLine().split("\n")[0]);
					
					// Iterate through each defensive player in file
					for(int j = 0; j < num_players; j++){
						// Get this players name from next line
						String player_name = scanner.nextLine().split("\n")[0];
						
						// Create a def_player with this name
						DefPlayer player = new DefPlayer(player_name);
						
						// Get this players def_tds and set that in player
						player.setDef_tds(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players picks and set that in player
						player.setPicks(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players fumbles and set that in player
						player.setFumbles(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players sacks and set that in player
						player.setSacks(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players blocks and set that in player
						player.setBlocks(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players safeties and set that in player
						player.setSafeties(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players pa and set that in player
						player.setPa(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players ya and set that in player
						player.setYa(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Add this player to the team
						team.addDefPlayer(player);
					}
					
					// Read in number of kickers from next line
					num_players = Integer.parseInt(scanner.nextLine().split("\n")[0]);
					
					// Iterate for each kicker
					for(int j = 0; j < num_players; j++){
						// Get this kickers name from the next line
						String player_name = scanner.nextLine().split("\n")[0];
						
						// Create a new kicker with this name
						Kicker player = new Kicker(player_name);
						
						// Get this players pat and set that in player
						player.setPat(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players field goals made in the first range and set that
						player.setFg0(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players field goals made in the second range and set that
						player.setFg1(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players field goals made in the final range and set that
						player.setFg2(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Get this players misses and set that in player
						player.setMisses(Integer.parseInt(scanner.nextLine().split("\n")[0]));
						
						// Add this player to team
						team.addKicker(player);
					}
					
					// Add this team to this league
					addTeam(team);
				}
			} catch (FileNotFoundException e) {
				// Do nothing
			}
		}
	}
	
	// Define a function to add a team to this league
	public void addTeam(Team team){
		// Check if team name is blank
		if(!team.getName().equalsIgnoreCase("")){
			// If not iterate through the teams array
			for(int i = 0; i < teams.size(); i++){
				// Check if this teams name is the same as the input teams name
				if(teams.get(i).getName().equalsIgnoreCase(team.getName())){
					// If so then return without doing anything
					return;
				}
			}
			
			// Otherwise if this team's name is not identical to any already existing
				// team names then add it to the league
			teams.add(team);
		}
	}

	// Define a function to find a team by its name
	public Team findTeam(String name){
		// Iterate through all teams in this league
		for(int i = 0; i < teams.size(); i++){
			// See if this teams name matches the given name were looking for
			if(name.equalsIgnoreCase(teams.get(i).getName())){
				// If so then return this team
				return teams.get(i);
			}
		}
		
		// If no team's names matched the given name then return null
		return null;
	}
	
	public ArrayList<Team> getTeams() {
		return teams;
	}
	
	// Define a function to sort teams by different metrics
	public void sort(int type){
		// Check if type is 0
		if(type == 0){
			// If so sort by pass_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pass_yds are less than the one after it
					if(teams.get(i).getPassYds() < teams.get(i+1).getPassYds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 1
		else if(type == 1){
			// If so sort by pass_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pass_tds are less than the one after it
					if(teams.get(i).getPassTds() < teams.get(i+1).getPassTds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false 
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 2
		else if(type == 2){
			// If so sort by picks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams picks are more than the one after it
					if(teams.get(i).getPicks() > teams.get(i+1).getPicks()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 3
		else if(type == 3){
			// If so sort by pass_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pass_2pt are less than the one after it
					if(teams.get(i).getPass2pt() < teams.get(i+1).getPass2pt()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 4
		else if(type == 4){
			// If so sort by rush_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rush_yds are less than the one after it
					if(teams.get(i).getRushYds() < teams.get(i+1).getRushYds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 5
		else if(type == 5){
			// If so sort by rush_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rush_tds are less than the one after it
					if(teams.get(i).getRushTds() < teams.get(i+1).getRushTds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 6
		else if(type == 6){
			// If so sort by rush_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rush_2pt are less than the one after it
					if(teams.get(i).getRush2pt() < teams.get(i+1).getRush2pt()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 7
		else if(type == 7){
			// If so sort by rec_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rec_yds are less than the one after it
					if(teams.get(i).getRecYds() < teams.get(i+1).getRecYds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 8
		else if(type == 8){
			// If so sort by rec_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rec_tds are less than the one after it
					if(teams.get(i).getRecTds() < teams.get(i+1).getRecTds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 9
		else if(type == 9){
			// If so sort by rec_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams rec_2pt are less than the one after it
					if(teams.get(i).getRec2pt() < teams.get(i+1).getRec2pt()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 10
		else if(type == 10){
			// If so sort by fumbles
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams fumbles are more than the one after it
					if(teams.get(i).getFumbles() > teams.get(i+1).getFumbles()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 11
		else if(type == 11){
			// If so sort by ret_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams ret_tds are less than the one after it
					if(teams.get(i).getRetTds() < teams.get(i+1).getRetTds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 12
		else if(type == 12){
			// If so sort by def_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams def_tds are less than the one after it
					if(teams.get(i).getDefTds() < teams.get(i+1).getDefTds()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 13
		else if(type == 13){
			// If so sort by def_picks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams def_picks are less than the one after it
					if(teams.get(i).getDefPicks() < teams.get(i+1).getDefPicks()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 14
		else if(type == 14){
			// If so sort by def_fumbles
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams def_fumbles are less than the one after it
					if(teams.get(i).getDefFumbles() < teams.get(i+1).getDefFumbles()){
						// If so swap these two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 15
		else if(type == 15){
			// If so sort by sacks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams sacks are less than the one after it
					if(teams.get(i).getSacks() < teams.get(i+1).getSacks()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 16
		else if(type == 16){
			// If so sort by blocks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams blocks are less than the one after it
					if(teams.get(i).getBlocks() < teams.get(i+1).getBlocks()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 17
		else if(type == 17){
			// If so sort by safeties
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pass_yds are less than the one after it
					if(teams.get(i).getSafeties() < teams.get(i+1).getSafeties()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 18
		else if(type == 18){
			// If so sort by pa
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pa are more than the one after it
					if(teams.get(i).getPA() > teams.get(i+1).getPA()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 19
		else if(type == 19){
			// If so sort by ya
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams ya are more than the one after it
					if(teams.get(i).getYA() > teams.get(i+1).getYA()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 20
		else if(type == 20){
			// If so sort by pat
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams pat are less than the one after it
					if(teams.get(i).getPAT() < teams.get(i+1).getPAT()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 21
		else if(type == 21){
			// If so sort by fg0
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams fg0 are less than the one after it
					if(teams.get(i).getFG0() < teams.get(i+1).getFG0()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 22
		else if(type == 22){
			// If so sort by fg1
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams fg1 are less than the one after it
					if(teams.get(i).getFG1() < teams.get(i+1).getFG1()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 23
		else if(type == 23){
			// If so sort by fg2
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams fg2 are less than the one after it
					if(teams.get(i).getFG2() < teams.get(i+1).getFG2()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}	
		}
		
		// Else check if type is 24
		else if(type == 24){
			// If so sort by misses
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams misses are more than the one after it
					if(teams.get(i).getMisses() > teams.get(i+1).getMisses()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 24
		else if(type == 24){
			// If so sort by points
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first team to second to last
				for(int i = 0; i < teams.size() - 1; i++){
					// Check if this teams points are less than the one after it
					if(teams.get(i).calculatePoints() < teams.get(i+1).calculatePoints()){
						// If so then swap the two teams
						Team temp = teams.get(i);
						teams.set(i, teams.get(i+1));
						teams.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
	}
	
	// Define a function to write the contents of this league to a file
	public void writeState(){
		// Open output file for writing
		File out_file = new File("league.txt");
		
		// Instantiate a new buffered file writer
		Writer output;
		try {
			output = new BufferedWriter(new FileWriter(out_file));
			
			// Write number of teams in this league to output file
			output.write(String.format("%d\n", teams.size()));
			
			// Iterate through teams array
			for(int i = 0; i < teams.size(); i++){
				// Save this team to a temporary variable
				Team temp_team = teams.get(i);
				
				// Write this teams name to the output file
				output.write(temp_team.getName()+"\n");
				
				// Get this teams off_players array and save it to a temporary variable
				ArrayList<OffPlayer> temp_off_players = temp_team.getOff_players();
				
				// Save the size of this teams offensive players array to num_players
				int num_players = temp_off_players.size();
				
				// Write this teams number of offensive players to the output file
				output.write(String.format("%d\n", num_players));
				
				// Iterate through this teams offensive players array
				for(int j = 0; j < num_players; j++){
					// Get this player and save it to a temporary variable
					OffPlayer this_player = temp_off_players.get(j);
					
					// Write this players name to the output file
					output.write(this_player.getName()+"\n");
					
					// Write this players pass_yds to file
					output.write(String.format("%d\n", this_player.getPass_yds()));
					
					// Write this players pass_tds to file
					output.write(String.format("%d\n", this_player.getPass_tds()));
					
					// Write this players picks to file
					output.write(String.format("%d\n", this_player.getPicks()));
					
					// Write this players pass_2pt to file
					output.write(String.format("%d\n", this_player.getPass_2pt()));
					
					// Write this players rush_yds to file
					output.write(String.format("%d\n", this_player.getRush_yds()));
					
					// Write this players rush_tds to file
					output.write(String.format("%d\n", this_player.getRush_tds()));
					
					// Write this players rush_2pt to file
					output.write(String.format("%d\n", this_player.getRush_2pt()));
					
					// Write this players rec_yds to file
					output.write(String.format("%d\n", this_player.getRec_yds()));
					
					// Write this players rec_tds to file
					output.write(String.format("%d\n", this_player.getRec_tds()));
					
					// Write this players rec_2pt to file
					output.write(String.format("%d\n", this_player.getRec_2pt()));
					
					// Write this players fumbles to file
					output.write(String.format("%d\n", this_player.getFumbles()));
					
					// Write this players ret_tds to file
					output.write(String.format("%d\n", this_player.getRet_tds()));
				}
				
				// Get this teams def_players array and save it to temporary variable
				ArrayList<DefPlayer> temp_def_players = temp_team.getDef_players();
				
				// Get size of def_players array and save it to num_players
				num_players = temp_def_players.size();
				
				// Output number of def_players to file
				output.write(String.format("%d\n", num_players));
				
				// Iterate through def_players array
				for(int j = 0; j < num_players; j++){
					// Get this player and save it to temporary variable
					DefPlayer this_player = temp_def_players.get(j);
					
					// Write this players name to file
					output.write(this_player.getName()+"\n");
					
					// Write this players def_tds to file
					output.write(String.format("%d\n", this_player.getDef_tds()));
					
					// Write this players picks to file
					output.write(String.format("%d\n", this_player.getPicks()));
					
					// Write this players fumbles to file
					output.write(String.format("%d\n", this_player.getFumbles()));
					
					// Write this players sacks to file
					output.write(String.format("%d\n", this_player.getSacks()));
					
					// Write this players blocks to file
					output.write(String.format("%d\n", this_player.getBlocks()));
					
					// Write this players safeties to file
					output.write(String.format("%d\n", this_player.getSafeties()));
					
					// Write this players pa to file
					output.write(String.format("%d\n", this_player.getPa()));
					
					// Write this players ya to file
					output.write(String.format("%d\n", this_player.getYa()));
				}
				
				// Get kickers array and save it to temporary variable
				ArrayList<Kicker> temp_kickers = temp_team.getKickers();
				
				// Get size of kickers array and save it to num_players
				num_players = temp_kickers.size();
				
				// Output number of kickers to file
				output.write(String.format("%d\n", num_players));
				
				// Iterate through kickers array 
				for(int j = 0; j < num_players; j++){
					// Get this kicker and save it to temporary variable
					Kicker this_player = temp_kickers.get(j);
					
					// Output this kickers name to file
					output.write(this_player.getName()+"\n");
					
					// Write this kickers pat to file
					output.write(String.format("%d\n", this_player.getPat()));
					
					// Write this kickers made field goals in first range to file
					output.write(String.format("%d\n", this_player.getFg0()));
					
					// Write this kickers made field goals in second range to file
					output.write(String.format("%d\n", this_player.getFg1()));
					
					// Write this kickers made field goals in third range to file
					output.write(String.format("%d\n", this_player.getFg2()));
					
					// Write this kickers misses to file
					output.write(String.format("%d\n", this_player.getMisses()));
				}
			}
			
			// Close output
			output.close();
		} catch (IOException e) {
			// Do nothing
		}
	}
	
	
}
